package edu.ege.thesis.phases.controller;

import java.util.ArrayList;
import java.util.Collection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.ege.thesis.exceptionhandling.AppException;
import edu.ege.thesis.model.VoidDO;
import edu.ege.thesis.query.Endpoints;
import edu.ege.thesis.query.QueryStrings;
import edu.ege.thesis.query.dao.SPARQLQueryDAO;

public class VoIDPhaseController{
	Logger logger = LoggerFactory.getLogger(SPARQLQueryDAO.class);	
	
	public Collection<VoidDO> eliminate() {
		Collection<VoidDO> provenanceRelatedVoidDOs = new ArrayList<VoidDO>();
		SPARQLQueryDAO sparqlQueryDAO = new SPARQLQueryDAO(Endpoints.sesameVoIDEndpoint,QueryStrings.voidEliminationQueryString);
		try {
		  boolean flag=sparqlQueryDAO.initialize();
		  if(flag==true){
			provenanceRelatedVoidDOs.addAll(sparqlQueryDAO.findProvenanceQueriedVoidDOs());
		  } else
			 throw new AppException("VoID DO list is null...");
		  } catch (AppException e) {
			// TODO Auto-generated catch block
			logger.error(e.getMessage());
		} finally {
		  sparqlQueryDAO.closeQueryConnection();
		}
		
		return provenanceRelatedVoidDOs;
	}

}
